<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <title>菜单管理</title>
  </head>
  <body>
    <div class="container-fluid">
      <!-- 路径导航 -->
	  <ol class="breadcrumb">
	    <li><a href="${ctx}/workbench">主页</a></li>
	    <li><a href="${ctx}/sidebar">菜单管理</a></li>
	    <li class="active">
	      <c:if test="${action eq 'create'}">添加菜单</c:if>
	      <c:if test="${action eq 'update'}">修改菜单</c:if>
	    </li>
	  </ol>
	  <!-- /路径导航 -->
	  
	  <div class="panel panel-default">
	    <div class="panel-heading">
	      <h3 class="panel-title">
	        <c:if test="${action eq 'create'}">添加菜单</c:if>
	        <c:if test="${action eq 'update'}">修改菜单</c:if>
	      </h3>
	    </div>
	    
	    <div class="panel-body">
	      <form class="form-horizontal" id="sidebar-form" action="${ctx}/sidebar/${action}" method="post" role="form">
	        <input type="hidden" id="sidebar-id" name="id" value="${sidebar.id}">
	        
	        <div class="form-group">
	          <label for="sidebar-name" class="col-sm-2 control-label">菜单名称</label>
	          <div class="col-sm-10">
	            <input type="text" class="form-control" id="sidebar-name" name="name" value="${sidebar.name}" placeholder="名称">
	          </div>
	        </div>
	        
	        <div class="form-group">
	          <label for="sidebar-name" class="col-sm-2 control-label">菜单代码</label>
	          <div class="col-sm-10">
	            <input type="text" class="form-control" id="sidebar-code" name="code" value="${sidebar.code}" placeholder="代码">
	          </div>
	        </div>
	        
	        <div class="form-group">
	          <label for="sidebar-name" class="col-sm-2 control-label">访问地址</label>
	          <div class="col-sm-10">
	            <input type="text" class="form-control" id="sidebar-href" name="href" value="${sidebar.href}" placeholder="地址">
	          </div>
	        </div>
	        
	        <div class="form-group">
	          <label for="sidebar-name" class="col-sm-2 control-label">上级菜单</label>
	          <div class="col-sm-10">
	            <label class="radio-inline">
	              <input type="radio" name="preSidebar.id" value="0" <c:if test="${empty sidebar.preSidebar }">checked="checked"</c:if>>侧边栏
	            </label>
	            <c:forEach items="${topSidebars}" var="top">
	              <c:if test="${sidebar.id ne top.id}">
	                <label class="radio-inline"> <input type="radio" name="preSidebar.id" value="${top.id}" <c:if test="${sidebar.preSidebar eq top }">checked="checked"</c:if>>${top.name}</label>
	              </c:if>
	            </c:forEach>
	          </div>
	        </div>
	        
	        <div class="form-group">
	          <div class="col-sm-offset-2 col-sm-10">
	            <button type="submit" class="btn btn-default"> 提 交 </button>
	            <button type="button" class="btn btn-default" onclick="history.back()"> 返 回 </button>
	          </div>
	        </div>
	      </form>
	    </div>
	    
	  </div>

	</div>
	
	<!-- 以下开始 加载JS动态效果 -->
	
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="${ctx}/static/jquery/jquery-1.11.1.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="${ctx}/static/bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
  </body>
</html>
